/**
工具管理接口
 **/
import { http } from "@/utils/http";

// 工具管理-table接口返回
type ResultTable = {
  total?: number;
  data?: Array<any>;
};
/**
 工具管理-工具台账接口
 **/
// 查询工具台账列表接口
export const queryToolLedger = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/toolInfo/queryListPage", {
    data
  });
};

// 工具台账-(不区分厂区)查询工具分页列表接口
export const queryAllToolLedger = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/toolInfo/queryListPageAll", {
    data
  });
};

// 查询工具台账列表接口-不分页
export const queryToolList = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/toolInfo/queryList", {
    data
  });
};

// 获取工具台账详情接口
export const getToolLedger = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>("post", "/digitaltwins/api/v1/toolInfo/getToolInfo", {
    data
  });
};
// 新增工具台账接口
export const addToolLedger = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolInfo/saveToolInfo", {
    data
  });
};

// 编辑工具台账接口
export const editToolLedger = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolInfo/updateToolInfo", {
    data
  });
};

// 提醒时间列表
export const getTimeList = () => {
  return http.request("post", "/digitaltwins/api/v1/toolInfo/getNoticeTimeList");
};

// 批量删除接口
export const deleteBatchTool = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolInfo/delBatchToolInfo", {
    data
  });
};
// 报废工具接口
export const scrapToolLedger = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolInfo/toolScrap", {
    data
  });
};
// 查询历史借用记录接口
export const queryToolLoanReturn = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolInfo/queryBorrowRecordList", {
    data
  });
};
// 自动生成工具编码接口
export const getToolInfoCode = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolInfo/getToolInfoCode", {
    data
  });
};

// 导入工具台账
export const getToolImport = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>(
    "post",
    "/digitaltwins/api/v1/toolInfo/importToolInfo",
    {
      data
    },
    {
      headers: {
        "Content-type": "multipart/form-data"
      }
    }
  );
};
// 工具管理-获取上传图片moduleName
export const getModuleName = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolBorrowRevert/getFileModelName", {
    data
  });
};
/**
 工具管理-工具借出/归还接口
 **/

// 查询工具台账借出归还列表接口
export const queryToolLoanList = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/toolBorrowRevert/queryListPage", {
    data
  });
};

// 查询工具借出归还详情接口
export const queryLoanDetail = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/toolBorrowRevert/getToolBorrowRevert", {
    data
  });
};
// 自动生成工具借用单
export const getToolBorrowCode = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolBorrowRevert/getBorrowRevertCode", {
    data
  });
};

// 新增工具借用单
export const addToolBorrowCode = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolBorrowRevert/saveToolBorrowRevert", {
    data
  });
};

// 批量归还工具
export const batchToolReturn = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolBorrowRevert/saveToolRevert", {
    data
  });
};

/******************************* 工具盘点组接口 *********************************/
// 工具盘点组-查询盘点组分页列表接口
export const queryToolGroup = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/toolTakeStockGroup/queryListPage", {
    data
  });
};
// 工具盘点组-查询盘点组不分页列表接口
export const queryToolGroupList = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/toolTakeStockGroup/queryList", {
    data
  });
};

// 工具盘点组-新增数据
export const addToolGroup = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolTakeStockGroup/saveTakeStockGroup", {
    data
  });
};

// 工具盘点组-修改数据
export const editToolGroup = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolTakeStockGroup/updateTakeStockGroup", {
    data
  });
};

// 工具盘点组-详情
export const getToolGroup = id => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStockGroup/getTakeStockGroup/${id}`);
};

// 工具盘点组-删除-禁用
export const delToolGroup = id => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStockGroup/delTakeStockGroup/${id}`);
};

/******************************* 工具盘点接口 *********************************/
// 工具盘点-查询盘点组分页列表接口
export const queryToolInventory = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", "/digitaltwins/api/v1/toolTakeStock/queryListPage", {
    data
  });
};

// 工具盘点-新增数据
export const addToolInventory = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolTakeStock/saveTakeStock", {
    data
  });
};

// 工具盘点-修改数据
export const editToolInventory = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolTakeStock/updateTakeStock", {
    data
  });
};

// 工具盘点-修改数据
export const saveToolInventory = (data?: Record<string, any>) => {
  return http.request("post", "/digitaltwins/api/v1/toolTakeStock/takeStockResult", {
    data
  });
};

// 工具盘点-详情
export const getToolInventory = id => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/toolTakeStock/getTakeStock/${id}`);
};

// 工具盘点-删除-禁用
export const delToolInventory = id => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStock/delTakeStock/${id}`);
};

// 查询对应的工具组的工具信息
export const queryGroupTool = id => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStockGroup/queryGroupToolInfoList/${id}`);
};

// 工具盘点编码
export const getTakeStockCode = () => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStock/getTakeStockCode`);
};

// 开始盘点
export const startTool = id => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStock/startTakeStock/${id}`);
};

/************ 盘点计划  **************/
//查询
export const getToolInventoryList = (data?: Record<string, any>) => {
  return http.request<ResultTable>("post", `/digitaltwins/api/v1/toolTakeStockPlan/queryPage`, {
    data
  });
};

// 查询计划状态枚举
export const getToolInventoryStatusList = () => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStockPlan/getPlanStatusList`);
};

// 删除
export const delToolInventoryList = (data?: string) => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStockPlan/del/${data}`);
};

// 盘点计划编码
export const getPlanCode = () => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStockPlan/getTakeStockPlanCode`);
};

// 新增/编辑
export const addToolInventoryList = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/toolTakeStockPlan/saveTakeStockPlan`, {
    data
  });
};

// 修改计划的执行周期
export const editToolInventoryPlanCycle = (data?: Record<string, any>) => {
  return http.request("post", `/digitaltwins/api/v1/toolTakeStockPlan/updateTakeStockPlan`, { data });
};

// 新增/编辑草稿
export const addToolInventoryDraft = (data?: Record<string, any>) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/toolTakeStockPlan/saveDraft`, {
    data
  });
};

// 详情
export const detailToolInventoryList = (data?: string) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/toolTakeStockPlan/get/${data}`);
};

// 取消
export const cancelToolInventoryList = (data?: string) => {
  return http.request<Record<string, any>>("post", `/digitaltwins/api/v1/toolTakeStockPlan/cancel/${data}`);
};
